import request from '@/config/axios'

// 客户 VO
export interface CustomerVO {
  id: number // 编号
  name: string // 客户名称
  detailAddress: string // 详细地址
  ownerUserName: string // 负责人姓名
  ownerUserId: number // 负责人的用户编号
  ownerTime: Date // 成为负责人的时间
  mobile: string // 手机
  telephone: string // 电话
  qq: string // QQ
  wechat: string // 微信
  email: string // 邮箱
  areaId: number // 地区编号
  remark: string // 备注
  status: number // 状态，0：待审核 1：通过 2：驳回
}

// 客户 API
export const CustomerApi = {
  //获得可分配人员
  // 营业部的deptid 115
  getOwner: async () => {
    return await request.get({ url: `system/user/page?pageNo=1&pageSize=100&deptId=115` })
  },

  //获得所有状态分类
  getAllStatus: async () => {
    return await request.get({ url: `/quote/customer/count` })
  },

  //获得所有已审批通过的客户
  getAllCustomer: async () => {
    return await request.get({ url: `/quote/customer/list` })
  },

  // 查询客户分页
  getCustomerPage: async (params: any) => {
    return await request.get({ url: `/quote/customer/page`, params })
  },

  // 查询客户详情
  getCustomer: async (id: number) => {
    return await request.get({ url: `/quote/customer/get?id=` + id })
  },
  // 管理员新增客户
  adminCreateCustomer: async (data: CustomerVO) => {
    return await request.post({ url: `/quote/customer/admin/create`, data })
  },

  // 新增客户
  createCustomer: async (data: CustomerVO) => {
    return await request.post({ url: `/quote/customer/create`, data })
  },

  // 修改客户
  updateCustomer: async (data: CustomerVO) => {
    return await request.put({ url: `/quote/customer/update`, data })
  },
  // 修改通过客户信息
  updateCustomer1: async (data: CustomerVO) => {
    return await request.put({ url: `/quote/customer/updateApprove`, data })
  },

  // 删除客户
  deleteCustomer: async (id: number) => {
    return await request.delete({ url: `/quote/customer/delete?id=` + id })
  },

  // 导出客户 Excel
  exportCustomer: async (params) => {
    return await request.download({ url: `/quote/customer/export-excel`, params })
  },
  //转换负责人
  changeOwner: async (data: any) => {
    return await request.put({ url: `/quote/customer/changeOwner`, data })
  },
  //审核客户
  auditCustomer: async (data: any) => {
    return await request.put({ url: `/quote/customer/audit`, data })
  }
}
